#include "thread_object.h"
#include <fstream>

static is_found = false

UserThread::UserThread()
{
	posix_queue_ = new posix_queue("queue_name");
	posix_queue_->queueFlags(O_RDONLY);
	posix_queue_->messageSize(14);
	posix_queue_->maxMessages(4);
}

UserThread::~UserThread()
{
	delete posix_queue_;
}

void UserThread::doSomething()
{
	std::ofstream fout;
	std::string file_name;
	std::string value;

	if (posix_queue_->open())
	{
		posix_queue_->receive(file_name);
		ifstream Fin(file_name.str());
		std::string FileOut(file_name);
		FileOut.append(".out");
		fout.open(FileOut.c_str());

		while (!Fin.eof() && !Fin.fail() && !is_found)
		{
			if (value == MagicCode)
			{
				is_found = true;
			}
		}
		Fin.close();
		fout.close();
	}
}